package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.Result;
import com.itheima.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wuzhouwei
 * @date 2020/4/19
 */
@RestController
@RequestMapping("/login")
public class LoginController {

    @Reference
    private UserService userService;

    @RequestMapping("/checkLogin")
    public Result checkLogin(String username){
        try {
            userService.checkLogin(username);
            return new Result(true,"");
        }catch (RuntimeException e){
            return new Result(false,"用户名已存在");
        }
        catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"用户名已存在");
        }
    }
}
